<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
/***************************
傳進參數
GambleID：操盤序號
Bet_Type：下注種類

OddsID：賠率序號
Odds：賠率值
Number：號碼

LottoID：樂透種類序號
StakeMoney：下注金額
CheckKey：檢查鍵值(防止下注重複)
***************************/
include_once("../config.inc.php");

session_start();
$objMemberInfo = $_SESSION["Member_Info"];
$arrOrderThrough = $_SESSION["OrderThrough"];
$_LangPath = "mainthroughcheckoutinsert";	//語言檔參數，務必放在最前面

include_once(__Member_Path."/logincheck.php");
include_once(__Language_Path."/selectlanguage_member.php");
include_once(__Modules_Path."/Wager.lib.php");
include_once(__Modules_Path."/WagerForm.lib.php");
include_once(__Common_Path."/Lotto.inc.php");
include_once(__Common_Path."/ExchangeRate.inc.php");
include_once(__Modules_Path."/LogRecord.lib.php");
include_once(__Modules_Path."/joinnumber.lib.php");
if($objMemberInfo -> isLock == '2'){
	$GLOBALS["errormessage"] = $_strStopWager;
	include("wager_error.php");
}

//Start Time
$startTime = Getmicrotime ();
$intLID = (int)$_data["LottoID"];
$intGID = (int)$_data["GambleID"];
$intLType = (int)$_arrLotto[$intLID]["LType"];
$intBT = (int)$_data["Bet_Type"];
$intStakeMoney = (int)$_data["StakeMoney"];
$_data["CheckKey1"] 	= trim($_data["CheckKey1"]);
$_data["CheckKey2"] 	= trim($_data["CheckKey2"]);

if(__isConnectToOtherWeb == 1){
	$flMemERate = (empty($objMemberInfo -> ExRate))?1:$objMemberInfo -> ExRate;
}else{
	$flMemERate = (empty($_ECRate[$objMemberInfo -> ERID]["Rate"]))?1:$_ECRate[$objMemberInfo -> ERID]["Rate"];
}
$flOdds = 1;
$PayOffMoney = null;
$PayOffMoney_second = null;
$JoinNumberValue = null;

//找出 Apoint
$intAN = 0;

//設定多少為一組 + 組合成功顯示可贏金額字串
$PayOffValue	= '<font color=red>$PayOffMoney</font>';

//檢查關鍵參數是否為空值
if(!$intLID || !$intLType || empty($intBT) || strlen($_data["CheckKey2"]) == 0 || strlen($_data["CheckKey1"]) == 0 || empty($intStakeMoney) || empty($intGID) || !is_array($arrOrderThrough)){
	$endTime = Getmicrotime ();
	$RunTime = 'RunTime:'. ($endTime - $startTime);
	$Err_Title = $_strMainThroughCkeckOutInsert["BetError"];
	$Err_Message = $_strMainThroughCkeckOutInsert["BetAgain"];
	$Err_HiddenMessage = "\nLine:".__LINE__.",\nPage:".__FILE__;
	include("wager_error.php");
}

//檢查下注金額是否為數值
/*if(!preg_match("/^[0-9]{0,7}$/", $intStakeMoney)){
	$endTime = Getmicrotime ();
	$RunTime = 'RunTime:'. ($endTime - $startTime);
	$Err_Title = $_strMainThroughCkeckOutInsert["BetError"];
	$Err_Message = $_strMainThroughCkeckOutInsert["StakeisString"];
	$Err_HiddenMessage = "\nLine:".__LINE__.",\nPage:".__FILE__;
	include("wager_error.php");
}*/

//不正確下注模式
if(!(($intBT == 15 && $intLID == 1) || ($intBT == 14 && $intLID == 5))){
	$endTime = Getmicrotime ();
	$RunTime = 'RunTime:'. ($endTime - $startTime);
	$Err_Title = $_strMainThroughCkeckOutInsert["BetError"];
	$Err_Message = $_strMainThroughCkeckOutInsert["ErrBetType"];
	$Err_HiddenMessage = "\nLine:".__LINE__.",\nPage:".__FILE__;
	include("wager_error.php");
}

//會員、代理商、總代理、股東退水質不得為空值
foreach($objMemberInfo -> arrCommission as $intGroup => $arrC){
	$arrComm[$intGroup] = $arrC[$intLID][$intBT];
	if( empty($arrComm[$intGroup]) ){
		$endTime = Getmicrotime ();
		$RunTime = 'RunTime:'. ($endTime - $startTime);
		$Err_Title = $_strMainThroughCkeckOutInsert["BetError"];
		$Err_Message = $_strMainThroughCkeckOutInsert["CommissionErr"];
		$Err_HiddenMessage = "\nLine:".__LINE__.",\nPage:".__FILE__;
		include("wager_error.php");
	}
}

include_once(__Common_Path."/limit/LottoLimit_".$intLID.".inc.php");
include_once(__Common_Path."/betparam/BetParam_".$intLID.".inc.php");

//移除 once 後面需要重新載入
$_arrMemStake = getWagerArrayGoldByDB($objMemberInfo -> ID);
if($_arrMemStake === false){
	PMA_mysql_query("ROLLBACK", $_ConnMaster);
	$Err_Message = ($_strWagerInsert[$GLOBALS["errormessage"]] != "")?$_strMainThroughCkeckOutInsert[$GLOBALS["errormessage"]]:$GLOBALS["errormessage"];
	$Err_HiddenMessage = $GLOBALS["errorhidden"];
	include("wager_error.php");
}
//include (__Root_Path."/tmp/credit-".$objMemberInfo -> ID.".php");

if(!is_array($_arrBetParam[$intBT][$intAN])){
	$Err_Message = "No Wager Relation Data!!";
	include("wager_error.php");
}
//===========================================================================//
//判斷最小單注或單場限額
$BetLimit = $objMemberInfo -> arrBetLimit[$intLID][$intBT];
$EventLimit = $objMemberInfo -> arrEventLimit[$intLID][$intBT];

if($_arrLottoLimit[$intBT][0] > 0){
	$_arrLottoLimit[$intBT][0] = floor($_arrLottoLimit[$intBT][0] / $flMemERate);
	if($_arrLottoLimit[$intBT][0] < $EventLimit)$EventLimit = $_arrLottoLimit[$intBT][0];
}

if($_arrLottoLimit[$intBT][1] > 0){
	$_arrLottoLimit[$intBT][1] = floor($_arrLottoLimit[$intBT][1] / $flMemERate);
	if($_arrLottoLimit[$intBT][1] < $BetLimit)$BetLimit = $_arrLottoLimit[$intBT][1];
}

//公司單注限額
$Com_BetLimit = floor($_arrBetParam[$intBT][$intAN]["Com_BetLimit"] / ($objMemberInfo -> Layer6Scale*$flMemERate));
if($Com_BetLimit < $BetLimit)$BetLimit = $Com_BetLimit;

$intMinStake = floor($_arrBetParam[$intBT][$intAN]["MinStake"] / $flMemERate);
//下注金額不能小於最小下注金額
if($intStakeMoney < $intMinStake){
	$endTime = Getmicrotime ();
	$RunTime = 'RunTime:'. ($endTime - $startTime);
	$Err_Title = $_strMainThroughCkeckOutInsert["BetError"];
	$Err_Message = $_strMainThroughCkeckOutInsert["NotUnderMinStake"]."(".number_format($intMinStake).")";
	$Err_HiddenMessage = "\nLine:".__LINE__.",\nPage:".__FILE__;
	include("wager_error.php");
}
//下注金額不能大於單注限額
if($intStakeMoney > $BetLimit){
	$endTime = Getmicrotime ();
	$RunTime = 'RunTime:'. ($endTime - $startTime);
	$Err_Title = $_strMainThroughCkeckOutInsert["BetError"];
	$Err_Message = $_strMainThroughCkeckOutInsert["NotOverMaxStake"]."(".number_format($BetLimit).")";
	$Err_HiddenMessage = "\nLine:".__LINE__.",\nPage:".__FILE__;
	include("wager_error.php");
}
/*下注總金額不能大於單場限額的剩餘額度
$intEvent = $_arrMemStake[$intBT][$intGID][$_data["Number"]];
if($intStakeMoney > ($EventLimit - $intEvent)){
	$Err_Title = $_strMainThroughCkeckOutInsert["BetError"];
	$Err_Message = $_strMainThroughCkeckOutInsert["NotOverEvenLimit"];
	$Err_Message .= $_strMainThroughCkeckOutInsert["EvenLimit"]."(".number_format($EventLimit).")<br>";
	$Err_Message .= $_strMainThroughCkeckOutInsert["ThisStake"]."(".number_format($intEvent).")";
	$Err_HiddenMessage = "\nLine:".__LINE__.",\nPage:".__FILE__;
	include("wager_error.php");
}
*/
//下注總金額不能大於信用額度
if($intStakeMoney > ($objMemberInfo -> CreditLine - $_arrMemStake["_SUM"])){
	$endTime = Getmicrotime ();
	$RunTime = 'RunTime:'. ($endTime - $startTime);
	$Err_Title = $_strMainThroughCkeckOutInsert["BetError"];
	$Err_Message = $_strMainThroughCkeckOutInsert["NotOverCredit"];
	$Err_Message .= $_strMainThroughCkeckOutInsert["MemCredit"]."(".number_format($objMemberInfo -> CreditLine).")<br>";
	$Err_Message .= $_strMainThroughCkeckOutInsert["UsedCredit"]."(".number_format($_arrMemStake["_SUM"]).")";
	$Err_HiddenMessage = "\nLine:".__LINE__.",\nPage:".__FILE__;
	include("wager_error.php");
}
//下注金額不能大於上層信額額度
if(isOverParentCredit($intStakeMoney*$flMemERate, $objMemberInfo -> SubID, $objMemberInfo -> SubCreditLine, $objMemberInfo -> MainID, $objMemberInfo -> MainCreditLine)){
	PMA_mysql_query("ROLLBACK", $_ConnMaster);
	if($GLOBALS["errormessage"] == "")$Err_Message = $_strMainThroughCkeckOutInsert["NotOverCredit"];
	$Err_Title = $_strMainThroughCkeckOutInsert["BetError"];
	$Err_HiddenMessage = "\nLine:".__LINE__.",\nPage:".__FILE__;
	include("wager_error.php");
}

//剩餘信用額度
$CreditSurplus = $objMemberInfo -> CreditLine - $_arrMemStake["_SUM"];

//===========================================================================//
//include_once(__Modules_Path."/RealBet.lib.php");
//是否上層停押
//$strParentID = $objMemberInfo -> SubID.",".$objMemberInfo -> MainID.",".$objMemberInfo -> StockID;
//if(!$strTop = GetOneStopWagerBet($intGID, $intBT, $_data["Number"], $strParentID)){
//	$Err_Message = $GLOBALS["errormessage"];
//	$Err_HiddenMessage = $GLOBALS["errorhidden"];
//	include("wager_error.php");
//}
//if($strTop == "Stop"){
//	$Err_Message = $_strMainThroughCkeckOutInsert["StopWager"];
//	include("wager_error.php");
//}
//===========================================================================//

//組合下注內容
$GroupCounter	= 0;
$ChoiceStatus = '<table class="left_mt_pg_choice" border="0" cellpadding="0" cellspacing="0">
  		    <tr class="left_mt_pg_choice">
    		      <td class="left_mt_pg_choice_type">'. $_strMainThroughCkeckOutInsert[MainThroughType] .'</td>
    		      <td class="left_mt_pg_choice_number">'. $_strMainThroughCkeckOutInsert[MainThroughNumber] .'</td>
    		      <td class="left_mt_pg_choice_odds">'. $_strMainThroughCkeckOutInsert[MainThroughOdds] .'</td>
  		    </tr>';

//交易開始
PMA_mysql_query("BEGIN", $_ConnMaster);

$strWagerConditions 	= null;
$ArrayCounter = 0;
//foreach ($arrOrderThrough as $intCounter => $arrBTValue) {
foreach ($arrOrderThrough as $intCounter => $objBTValue) {
	//if (!is_array($arrBTValue))continue;

	//foreach ($arrBTValue as $intBTTmp => $objBTValue) {
		if (!is_object($objBTValue))continue;
		$intBTTmp = $objBTValue -> BetType;

		$ArrayCounter++;
		$ArrayNumber[$ArrayCounter]	= $intCounter.$objBTValue -> Type;
		$ArrayBetTypeList[$ArrayCounter]= $intBTTmp;
		$ArrayOdds[$ArrayCounter]	= $objBTValue -> Odds;
		$ArrayOddsID[$ArrayCounter]	= $objBTValue -> OddsID;
		$ChoiceStatus .= '<tr class="left_mt_pg_choice_con"><td class="left_mt_pg_choice_type_con">'. $_strMainThroughCkeckOutInsert['BetTypeTitle'.$intCounter] .'</td>';

		$arrGDate = getWagerArrayData($intLID, $intLType, $intGID, $intBTTmp, $intCounter.$objBTValue->Type , $objBTValue -> OddsID, $objBTValue -> Odds - 1);
		if($arrGDate["isError"]){
			PMA_mysql_query("ROLLBACK", $_ConnMaster);
			$endTime = Getmicrotime ();
			$RunTime = 'RunTime:'. ($endTime - $startTime);
			$Err_Message = $_strMainThroughCkeckOutInsert[$arrGDate["Err_Message"]];
			include("wager_error.php");
		} elseif($arrGDate["isMessage"]){
			PMA_mysql_query("ROLLBACK", $_ConnMaster);
			$endTime = Getmicrotime ();
			$RunTime = 'RunTime:'. ($endTime - $startTime);
			$Err_Message = $_strMainThroughCkeckOutInsert[$arrGDate["Message"]];
			if($arrGDate["Message"] == "OddsChange")$isGoBack = true;
			include("wager_error.php");
		}
		$flOdds = $flOdds * $objBTValue -> Odds;
    	$strWagerConditions	.= getWagerConditions($intLType, $intBTTmp, $intCounter.$objBTValue -> Type, $objBTValue -> Odds, $arrGDate["SerialNo"]) .'<br>';

		//組合下注內容
		switch($intLID.'_'.$intBTTmp) {
			case '1_12':
			case '5_11':
				if ($objBTValue -> Type == 0) {
					$ChoiceStatus .= '<td class="left_mt_pg_choice_number_con">'. $_strMainThroughCkeckOutInsert[SingleTitle] .'</td>';
				} else {
					$ChoiceStatus .= '<td class="left_mt_pg_choice_number_con">'. $_strMainThroughCkeckOutInsert[DualTitle] .'</td>';
				}
				break;

			case '1_13':
			case '5_12':
				if ($objBTValue -> Type == 0) {
					$ChoiceStatus .= '<td class="left_mt_pg_choice_number_con">'. $_strMainThroughCkeckOutInsert[LargeTitle] .'</td>';
				} else {
					$ChoiceStatus .= '<td class="left_mt_pg_choice_number_con">'. $_strMainThroughCkeckOutInsert[SmallTitle] .'</td>';
				}
				break;

			case '5_13':
				if ($objBTValue -> Type == 0) {
					$ChoiceStatus .= '<td class="left_mt_pg_choice_number_con">'. $_strMainThroughCkeckOutInsert[SOddTitle] .'</td>';
				} else {
					$ChoiceStatus .= '<td class="left_mt_pg_choice_number_con">'. $_strMainThroughCkeckOutInsert[SEvenTitle] .'</td>';
				}
				break;

			case '1_14':
				if ($objBTValue -> Type == 0) {
					$ChoiceStatus .= '<td class="left_mt_pg_choice_number_con">'. $_strMainThroughCkeckOutInsert[RedTitle] .'</td>';
				} elseif ($objBTValue -> Type == 1) {
					$ChoiceStatus .= '<td class="left_mt_pg_choice_number_con">'. $_strMainThroughCkeckOutInsert[BlueTitle] .'</td>';
				} else {
					$ChoiceStatus .= '<td class="left_mt_pg_choice_number_con">'. $_strMainThroughCkeckOutInsert[GreenTitle] .'</td>';
				}
				break;
		}
    	$ChoiceStatus	.= '<td class="left_mt_pg_choice_odds_con">'. $objBTValue -> Odds .'</td></tr>';
	//}
}
$ChoiceStatus .= '<tr class="left_mt_pg_choice_status"><td colspan="3" class="left_mt_pg_choice_status">'. $ArrayCounter .'&nbsp;'. $_strMainThroughCkeckOutInsert[LinkNumber] .'&nbsp;1</td></tr></table>';

//判斷是否最少過兩關
if ($ArrayCounter < 2) {
	PMA_mysql_query("ROLLBACK", $_ConnMaster);
	$endTime 		= Getmicrotime ();
	$RunTime 		= 'RunTime:'. ($endTime - $startTime);
	$Err_Message 		= $_strMainThroughCkeckOutInsert["ErrorTimesMessage"];
	include("wager_error.php");
}

$arrWCont["Content_x"] = $strWagerConditions;

//組合成功顯示可贏金額字串
$PayOffMoney = floor($intStakeMoney * ($flOdds - 1) * 100) / 100;
eval("\$PayOffValue = \"$PayOffValue\";");

//組合陣列 for bet_BetListContent 用
$arrWCont["GameDate_x"] = $arrGDate["GameDate"];
$arrWCont["checkkey_x"] = str_replace("0.", ($_data["CheckKey2"])."-", $_data["CheckKey1"]);
$arrWCont["Content_x"] = $strWagerConditions;
$flMemPayOff = ($intStakeMoney*($flOdds - 1));
$arrWCont["GambleType"] = $objMemberInfo -> GambleType;
$arrWCont["MemAccount_x"] = $objMemberInfo -> Account;
$arrWCont["isBlack"] = $objMemberInfo -> isBlack;

$arrWList["LottoID"] = $arrGDate["LottoID"];
$arrWList["LType"] = $intLType;
$arrWList["Bet_Type"] = $intBT;
$arrWList["GambleID"] = $arrGDate["GambleID"];
$arrWList["Number"] = $ArrayCounter;
$arrWList["PayupDate_x"] = $arrGDate["PayupDate"];
$arrWList["MemPayOff"] = $flMemPayOff;
$arrWList["MemID"] = $objMemberInfo -> ID;
$arrWList["MemExchangeRate"] = $flMemERate;
$arrWList["MemCurrency"] = $objMemberInfo -> ERID;
$arrWList["MemStake"] = $intStakeMoney;
$arrWList["MemCommission"] 	= 1 - ($arrComm[1] / 100);
$arrWList["SubID"] = $objMemberInfo -> SubID;
$arrWList["SubCommission"] 	= 1 - ($arrComm[2] / 100);
$arrWList["SubRate"] = $objMemberInfo -> SubScale;
$arrWList["MainID"] = $objMemberInfo -> MainID;
$arrWList["MainCommission"] 	= 1 - ($arrComm[3] / 100);
$arrWList["MainRate"] = $objMemberInfo -> MainScale;
$arrWList["StockID"] = $objMemberInfo -> StockID;
$arrWList["StockCommission"] 	= 1 - ($arrComm[4] / 100);
$arrWList["StockRate"] = $objMemberInfo -> StockScale;
$arrWList["DirectorID"] = $objMemberInfo -> DirectorID;
$arrWList["DirectorCommission"] 	= 1 - ($arrComm[5] / 100);
$arrWList["DirectorRate"] = $objMemberInfo -> DirectorScale;
$arrWList["Layer6ID"] = $objMemberInfo -> Layer6ID;
$arrWList["Layer6Commission"] 	= 1 - ($arrComm[6] / 100);
$arrWList["Layer6Rate"] = $objMemberInfo -> Layer6Scale;

if($arrWList["StockCommission"] < 0 || $arrWList["StockCommission"] >= 0.2 || $arrWList["StockCommission"] < $arrWList["MainCommission"] || $arrWList["MainCommission"] < $arrWList["SubCommission"] || $arrWList["SubCommission"] < $arrWList["MemCommission"]){
	PMA_mysql_query("ROLLBACK", $_ConnMaster);
	$Err_Message = "Commission Error!!";
	include("wager_error.php");
}

//$EventLimit  = 單場限額 - 本次下注...
$MaxEventLimit = $EventLimit - $intStakeMoney;

//$MaxEventLimitGap = 最高差額 - 本次下注...
$JoinNumberValue  = null;
$MaxEventLimitGap = $_arrBetParam[$intBT][$intAN][MaxStakeGap] - $intStakeMoney;

//取得此會員此場已下注號碼的累積金額
$arrBetListStake	= get_BetListStake($objMemberInfo->ID, $intGID, $intBT);
if($arrBetListStake["isError"]){
	PMA_mysql_query("ROLLBACK", $_ConnMaster);
	$endTime 		= Getmicrotime ();
	$RunTime 		= 'RunTime:'. ($endTime - $startTime);
	$Err_Message 		= $_strMainThroughCkeckOutInsert[$arrBetListStake["ErrorMessage"]];
	$Err_HiddenMessage 	= $arrBetListStake["ErrorHiddenMessage"];
	include("wager_error.php");
} elseif ($arrBetListStake["MemStake"] > $MaxEventLimit) {
	//比對此會員此場已下注號碼的累積金額是否已超過單場限額
	PMA_mysql_query("ROLLBACK", $_ConnMaster);
	eval("\$Err_Message = \"$_strMainThroughCkeckOutInsert[OverEvenLimit]\";");
	$endTime 		= Getmicrotime ();
	$RunTime 		= 'RunTime:'. ($endTime - $startTime);
	$Err_Title		= $_strMainThroughCkeckOutInsert["BetError"];
	$Err_HiddenMessage	= '<br>'. $_strMainThroughCkeckOutInsert["EvenLimits"]."(".number_format($EventLimit).")<br>";
	$Err_HiddenMessage	.= $_strMainThroughCkeckOutInsert["ThisStake"]."(".number_format($arrBetListStake[$Number_Value] + $intStakeMoney).")";
	$Err_HiddenMessage	.= "\nLine:".__LINE__.",\nPage:".__FILE__;
	include("wager_error.php");
} elseif ($arrBetListStake["MemStake"] > $MaxEventLimitGap) {
	//比對此會員此場已下注號碼的累積金額是否已超過最高差額
	PMA_mysql_query("ROLLBACK", $_ConnMaster);
	eval("\$Err_Message = \"$_strMainThroughCkeckOutInsert[OverEvenGapLimit]\";");
	$endTime 		= Getmicrotime ();
	$RunTime 		= 'RunTime:'. ($endTime - $startTime);
	$Err_Title		= $_strMainThroughCkeckOutInsert["BetError"];
	$Err_HiddenMessage	= '<br>'. $_strMainThroughCkeckOutInsert["EvenGapLimits"]."(".number_format($EventLimit).")<br>";
	$Err_HiddenMessage	.= $_strMainThroughCkeckOutInsert["ThisStake"]."(".number_format($arrParlaysNumberEvenGap[$Number_Value] + $intStakeMoney).")";
	$Err_HiddenMessage	.= "\nLine:".__LINE__.",\nPage:".__FILE__;
	include("wager_error.php");
}

//寫入注單
$arrBetData = InsertWagerToDB($arrWCont, $arrWList);
if($arrBetData["isError"]){
	PMA_mysql_query("ROLLBACK", $_ConnMaster);
	$endTime = Getmicrotime ();
	$RunTime = 'RunTime:'. ($endTime - $startTime);
	$Err_Message = $_strMainThroughCkeckOutInsert[$arrBetData["ErrorMessage"]];
	$Err_HiddenMessage = $arrBetData["ErrorHiddenMessage"];
	include("wager_error.php");
}

//寫入下注號碼 ParlaysNumber
$arrBetParlaysData = InsertParlaysThroughToDB($arrBetData["BetID"], $arrWList["GambleID"], $ArrayBetTypeList, $ArrayNumber, $ArrayOdds, $ArrayOddsID);
if($arrBetParlaysData["isError"]){
	PMA_mysql_query("ROLLBACK", $_ConnMaster);
	$endTime = Getmicrotime ();
	$RunTime = 'RunTime:'. ($endTime - $startTime);
	$Err_Message = $_strMainThroughCkeckOutInsert[$arrBetParlaysData["ErrorMessage"]];
	$Err_HiddenMessage = $arrBetParlaysData["ErrorHiddenMessage"];
	include("wager_error.php");
}

//產生累積注額陣列
if(!getWagerArrayGold($objMemberInfo -> ID)){
	PMA_mysql_query("ROLLBACK", $_ConnMaster);
	$endTime = Getmicrotime ();
	$RunTime = 'RunTime:'. ($endTime - $startTime);
	$Err_Message = $GLOBALS["errormessage"];
	$Err_HiddenMessage = $GLOBALS["errorhidden"];
	include("wager_error.php");
}

//更新剩餘信用額度
include (__Root_Path."/tmp/credit-".$objMemberInfo -> ID.".php");
$CreditSurplus	= $objMemberInfo->CreditLine - $_arrMemStake["_SUM"];

//交易完成
PMA_mysql_query("COMMIT", $_ConnMaster);
unset($_SESSION[OrderThrough]);

AddData_Log($objMemberInfo -> ID,"下注成功 ", $arrBetData["LogData"]);
$Err_Message = "Success!!";
@mysql_close($$_Conn);
include("throughcheckout_success.php");
?>